package com.edu.javaweb.service.impl;

import com.edu.javaweb.pojo.HolidayInformation;
import com.edu.javaweb.pojo.Student;
import com.edu.javaweb.pojo.StudentRecord;
import com.edu.javaweb.service.StudentRecordService;
import com.edu.javaweb.mapper.StudentRecordMapper;
import com.edu.javaweb.vo.Rule;
import com.edu.javaweb.vo.StudentRecordVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpSession;
import java.util.List;

@Service
public class StudentRecordServiceImpl implements StudentRecordService {
    @Autowired
    private StudentRecordMapper studentRecordMapper;
    @Override
    public void insStuRecord(StudentRecord studentRecord, HttpSession session) {
        studentRecordMapper.insStuRecord(studentRecord);
        Student student=(Student) session.getAttribute("student");
        HolidayInformation holidayInformation=(HolidayInformation) session.getAttribute("holidayInformation");
        studentRecordMapper.insStuAndStuRecord(student.getId(),studentRecord.getId(),holidayInformation.getId());

    }

    @Override
    public List<StudentRecord> stuHisRecord(HttpSession session) {
        Student student=(Student) session.getAttribute("student");
        Integer stu = student.getId();
        return studentRecordMapper.findByStuId(stu);
    }

    @Override
    public List<StudentRecordVo> findByStuRecordGroup(Rule rule) {
        return studentRecordMapper.findByStuRecordGroup(rule);
    }
}
